package com.taotao.controller;

import com.taotao.service.PictureService;
import com.taotao.util.JsonUtils;
import com.taotao.util.PictureResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * Created by Administrator on 2018/4/27.
 */
@Controller
@RequestMapping("/pic")
public class PictureController {

    @Autowired
    private PictureService pictureService;

    @RequestMapping("/upload")
    @ResponseBody
    public String uploda(MultipartFile uploadFile) throws Exception {
        Map result=pictureService.uploadFile(uploadFile);
        //为了保证功能的兼容性需要吧result转换成json格式的字符串
        String json= JsonUtils.objectToJson(result);
        //返回上传结果
        return json;

    }
}
